package com.zkingsoft.zkingbase.presenter;

import android.content.Context;
import com.zkingsoft.zkingbase.view.INetBaseView;

/**
 * Created by ytf on 2017/3/6 006.
 * Description:MVP presenter 提供数据给view层
 * 泛型T是view的类型，V是要提供给view层的数据
 */

public class UserRegisterPresenter<T extends INetBaseView, D> implements IBasePresenter<D>
{
    public INetBaseView<D> iView;
    private Context mContext;

    public UserRegisterPresenter(T iv, Context context)
    {
        iView = iv;
        mContext = context;
    }

    @Override
    public void onStart()
    {
        iView.showProgress(null);
    }

    @Override
    public void onSuccess(D data, Object obj)
    {
        //成功后隐藏等待框
        iView.hideProgress(null);
        iView.loadSuccess(data, obj);
    }

    @Override
    public void onFailed(String msg, Throwable e)
    {
        //失败后隐藏等待框
        iView.hideProgress(null);
        iView.loadFailed(msg, e);
    }

    @Override
    public void onComplete()
    {
        //完成后隐藏等待框
        iView.hideProgress(null);
    }
}
